//
//  SNDeleteCommunityManager.m
//  app
//
//  Created by 王少宁 on 15/11/10.
//  Copyright © 2015年 hdaren. All rights reserved.
//

#import "SNDeleteCommunityManager.h"

@interface SNDeleteCommunityManager ()
@property (nonatomic,strong) JKHttpClient * jkHttp;
@property (nonatomic,strong) SNUniteUrl * uniteUrl;
@end

@implementation SNDeleteCommunityManager

+ (SNDeleteCommunityManager *)shareManager
{
    AS_SINGLETON(SNDeleteCommunityManager, manager, {
        
        manager = [[SNDeleteCommunityManager alloc]init];
        manager.jkHttp = [[JKHttpClient alloc]init];
        manager.uniteUrl = [SNUniteUrl shareUniteUrl];
    })
    
    return manager;
}

- (void)deleteCommunityWithResult:(SNDeleteCommunityResult *)result houseID:(NSString *)houseID cmid:(NSString *)cmid
{
    if ([self.jkHttp isRunning]) {
        return;
    }
    
    NSDictionary * params = @{@"id":houseID ? houseID : @"",
                              @"uid":[[NSUserDefaults standardUserDefaults] objectForKey:@"uid"],
                              @"cmid":cmid};
    
    result.success = NO;
    result.failure = YES;
    
    [self.jkHttp get:self.uniteUrl.deleteMyCommunityUrl params:params result:^(JKResponse *resp) {
        
        if (resp.OK) {
            result.success = YES;
            result.failure = NO;
        }
        
        [result invoke];
    }];
}

@end
